<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>工单计划任务</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <style type="text/css">
        .detail {
            padding-right: 20px!important;
        }

        h5 {
            color: #0062CC;
        }
    </style>
</head>

<body>
    <div class="mui-content">
    	<div id="ordrListsContent">
        <script type="text/template" id="itemslist">
            {{each datas as item i}}
            <div class="mui-card">
                <ul class="mui-table-view mui-table-view-chevron">
                    <li class="mui-table-view-cell mui-collapse">
                        <a class="mui-navigate-right" href="#">序号：{{item.tasksequence}}
						<span class="mui-badge mui-badge-inverted">状态:{{item.status}}</span>
					</a>
                        <ul class="mui-table-view mui-table-view-chevron">
                            <li class="mui-table-view-cell">任务：{{item.jptask}}</li>
                            <li class="mui-table-view-cell">持续时间：{{item.taskduration}}</li>
                            <li class="mui-table-view-cell">任务说明：{{item.description}}</li>
                        </ul>
                    </li>
                </ul>
                <div class="mui-card-footer">
                    <a class="mui-card-link" onclick="openTastEdit('{{item.jobtaskid}}')">修改</a>
                    <a class="mui-card-link"></a>
                    <a class="mui-card-link" tapmode onclick="Delete('deletePlanTask',{jobtaskid: {{item.jobtaskid}}})">删除</a>
                </div>
            </div>
            {{/each}}
        </script>
	</div>
	<div class="fixed_btn mui-hidden" id="plan" onclick="openSaveWin('order_plan_time', '填写任务计划时间',{wonum: api.pageParam.wonum, workorderid: api.pageParam.workorderid})">
        <i class="edit-icon"></i>添加计划时间
    </div>
    <div class="fixed_btn mui-hidden" id="actual" onclick="openSaveWin('order_actual_time', '填写任务实际时间',{wonum: api.pageParam.wonum, workorderid: api.pageParam.workorderid})">
		<i class="edit-icon"></i>添加实际时间
	</div>
    </div>
    
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    var cRegion = '',searchText, title;
    apiready = function() {
        onLoadData(curPage, false);
        if(api.pageParam.isPlan == 1) {
        	$api.removeCls($api.byId('plan'),'mui-hidden')
        	title = '计划'
        } else {
        	$api.removeCls($api.byId('actual'),'mui-hidden')
        	title = '实际'
        }
        scrollToBottomHandler(function() {
            if (!loadEnd) { // 没有结束时继续加载
                curPage++;
                onLoadData(curPage, true);
            } else { // 告诉到底了
                EndToast('到底了');
            }
        })
        Refresh(function() {
            tjsearch();
        });
        api.addEventListener({
            name: 'refersh'
        }, function(ret, err) {
        	if (ret.value.isrefersh == 'yes') {
        		tjsearch();
        	}
        });
        api.addEventListener({
            name: 'navitembtn'
        }, function(ret, err) {
        	if (!canModify()){
				return;
			}
            if (ret.type == 'right') {
                openSaveWin('work_order_manage_tast_add', '新增'+title+'任务', {
                    wonum: api.pageParam.wonum
                });
            }
        })
        api.parseTapmode();
    }

    function openTastEdit(jobtaskid) {
    	if (!canModify()){
			return;
		}
        openSaveWin('work_order_manage_tast_edit', '修改'+title+'任务', {
            jobtaskid: jobtaskid
        })
    }

    function onLoadData(page, load) {
        searchText = $api.val($api.byId('searchText'));
        ajaxrd("queryPlanTaskList", {
            wonum: api.pageParam.wonum,
            pageNo: curPage,
            pageSize: 10
        }, function(ret, err) {
            api.refreshHeaderLoadDone();
            if (ret.list) {
                AddData('itemslist', 'ordrListsContent', ret.list, load);
                if (ret.list.length < 10) {
                    loadEnd = true
                }
            } else {
                Toast('暂无数据');
            }
        })
    }
</script>

</html>
